#ifndef GTL_CONCURRENCY_THREADS_HEADER_GUARD
#define GTL_CONCURRENCY_THREADS_HEADER_GUARD

namespace GTL
{
  namespace Concurrency
  {
#ifdef GTL_OS_WINDOWS
#undef Yield

		typedef unsigned int ThreadID;

		namespace SystemImplemented 
		{
			extern "C" __declspec(dllimport) int __stdcall SwitchToThread();
			extern "C" __declspec(dllimport) void __stdcall Sleep(unsigned int dwMilliseconds); 
			extern "C" __declspec(dllimport) ThreadID __stdcall GetCurrentThreadId();
		}

    inline void YieldThread()
    {
      SystemImplemented::SwitchToThread();
    }

		inline void Sleep(unsigned int ms)
		{
			SystemImplemented::Sleep(ms);
		}

    inline ThreadID GetCurrentThreadID()
    {
      return SystemImplemented::GetCurrentThreadId();
    }

#elif defined(GTL_OS_UNIX)

		namespace SystemImplemented 
		{
			extern "C" pid_t gettid();
			extern "C" int usleep(useconds_t usec);
		}

		inline void YieldThread()
    {
      sched_yield();
    }

    typedef unsigned int ThreadID;

    inline ThreadID GetCurrentThreadID()
    {
      return (ThreadID)SystemImplemented::gettid();
    }

		inline void Sleep(unsigned int ms)
		{
			SystemImplemented::usleep(ms*1000);
		}
#endif
  }
}

#endif